<?php
class Member_model extends CI_Model {

	private $tbl_member= 'bkw_members';

    function __construct()
    {
        parent::__construct();
    }

    function isEMailExists($emailId){
	
		$query = $this->db->query("SELECT count(*) as mem_count from bkw_members where mem_email='".$emailId."' and  rec_status=1");
		$record=@array_pop($query->result());
		if($record->mem_count>0){
			return true;
		}else{

			return false;
		}

	}


	function getList(){

	$this->load->database();
    $this->load->library('table');
    $query = $this->db->query("SELECT *  from bkw_members where  rec_status=1");
    $table = $this->table->generate($query);
   	return $table; 

	}

	
	function list_all(){
		$this->db->order_by('mem_id','asc');
		return $this->db->get($tbl_member);
	}
	
	function count_all(){
		return $this->db->count_all($this->tbl_member);
	}
	
	function get_paged_list($limit = 10, $offset = 0){
		$this->db->order_by('mem_id','asc');
		return $this->db->get($this->tbl_member, $limit, $offset);
	}
	
	function get_by_id($id){
		$this->db->where('mem_id', $id);
		return $this->db->get($this->tbl_member);
	}
	
	function save($person){
		$this->db->insert($this->tbl_member, $person);
		return $this->db->insert_id();
	}
	
	function update($id, $person){
		$this->db->where('mem_id', $id);
		$this->db->update($this->tbl_member, $person);
	}
	
	function delete($id){
		$this->db->where('mem_id', $id);
		$this->db->delete($this->tbl_member);
	}

	
}
?>